import { getUserInfo } from "@/core/api/my.js";
import { appauth } from "@/core/api/index.js";
import Vue from 'vue';
import { hex_md5 } from '@/utils/md5.js'
const state = {
    userInfo: {},
	openid:''
};

const getters = {
};

const mutations = {
    setUserInfo(state, data) {
        state.userInfo = data;
    },
};

const actions = {
    async getUserInfo(content, data) {
		wx.login({
		   async success (res) {
			   let params = {
				   code:res.code
			   }
			    let req = await appauth(params);
				console.log(req,'登录请求')
				let data = req._data.userInfo
				content.commit("setUserInfo", data);
				uni.setStorageSync('_access_token', data.token);
			},})
    }
};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions,
};
